﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>

    <h1>CountConverter</h1>
<p>Count converter finds the count of elements in a collection during data binding using specified property. The converter can count distinct or all property of elements within nested collections. Nested levels are specified using a CountParameter object and passed as ConverterParameter duding binding.</p>
<p><strong>Namespace </strong></p>
<p><code>StoreAppLib.Converters</code></p>
<p><strong>Using CountConverter</strong></p>
<p>To use CountConverter in your project, add the reference to StoreAppLib project or&nbsp; install StoreAppLib from Visual Studio &quot;Manage NuGet Packages&quot; tool.</p>
<p>To use the converter while binding first declare the converter and count parameter in the App.xaml file.</p>
<p><code><span style="color: blue; font-size: 9.5pt;" lang="EN">&lt;</span><span style="color: #a31515; font-size: 9.5pt;" lang="EN">Application<br /></span><span style="color: black; font-size: 9.5pt;" lang="EN">&nbsp;&nbsp; </span><span style="color: red; font-size: 9.5pt;" lang="EN"><strong>xmlns</strong></span><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">:</span></strong><strong><span style="color: red; font-size: 9.5pt;" lang="EN">storeApp</span></strong><strong><span style="color: red; font-size: 9.5pt;">Converter</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">="using:StoreAppLib.Converters"</span></strong><span style="color: blue; font-size: 9.5pt;" lang="EN"><br /></span><span style="color: blue; font-size: 9.5pt;">&nbsp;&nbsp; ...</span><span style="color: black; font-size: 9.5pt;"> </span><span style="color: blue; font-size: 9.5pt;" lang="EN">&gt;<br /></span><span style="color: black; font-size: 9.5pt;" lang="EN">&nbsp;&nbsp; </span><span style="color: blue; font-size: 9.5pt;" lang="EN">&lt;</span><span style="color: #a31515; font-size: 9.5pt;" lang="EN">Application.Resources</span><span style="color: blue; font-size: 9.5pt;" lang="EN">&gt;<br /></span><span style="color: black; font-size: 9.5pt;" lang="EN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue; font-size: 9.5pt;" lang="EN">&lt;</span><span style="color: #a31515; font-size: 9.5pt;" lang="EN">ResourceDictionary</span><span style="color: blue; font-size: 9.5pt;" lang="EN">&gt;</span></code></p>
<p><code><strong><span style="color: black; font-size: 9.5pt;" lang="EN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">&lt;</span></strong><strong><span style="color: red; font-size: 9.5pt;" lang="EN">storeApp</span></strong><strong><span style="color: red; font-size: 9.5pt;">Converter</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">:</span></strong><strong><span style="color: #a31515; font-size: 9.5pt;" lang="EN">CountConverter <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong><strong><span style="color: red; font-size: 9.5pt;" lang="EN">x</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">:</span></strong><strong><span style="color: red; font-size: 9.5pt;" lang="EN">Key</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">="CountConverter" /&gt;</span></strong><strong><span style="color: black; font-size: 9.5pt;" lang="EN">&nbsp;&nbsp;&nbsp;<br /></span></strong></code><code><strong><span style="color: black; font-size: 9.5pt;" lang="EN"><br /><code><strong><span style="color: black; font-size: 9.5pt;" lang="EN">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">&lt;</span></strong><strong><span style="color: red; font-size: 9.5pt;" lang="EN">storeApp</span></strong><strong><span style="color: red; font-size: 9.5pt;">Converter</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">:</span></strong><strong><span style="color: #a31515; font-size: 9.5pt;" lang="EN">CountParameter</span></strong><strong><span style="color: red; font-size: 9.5pt;" lang="EN"> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></strong></code><code><strong><span style="color: red; font-size: 9.5pt;" lang="EN">x</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">:</span></strong><strong><span style="color: red; font-size: 9.5pt;" lang="EN">Key</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">="LanguageCountParameter"<strong><span style="color: red; font-size: 9.5pt;" lang="EN">&nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Property</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">="Employees.Languages.Name"<strong><span style="color: red; font-size: 9.5pt;" lang="EN">&nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN"><strong><span style="color: red; font-size: 9.5pt;" lang="EN">Distinct</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">="False"</span></strong></span></strong></span></strong> /&gt;</span></strong><strong><span style="color: black; font-size: 9.5pt;" lang="EN"> &nbsp;<br /><code><strong><span style="color: black; font-size: 9.5pt;" lang="EN"><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">&lt;</span></strong><strong><span style="color: red; font-size: 9.5pt;" lang="EN">storeApp</span></strong><strong><span style="color: red; font-size: 9.5pt;">Converter</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">:</span></strong><strong><span style="color: #a31515; font-size: 9.5pt;" lang="EN">CountParameter</span></strong><strong><span style="color: red; font-size: 9.5pt;" lang="EN"> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></strong></code><code><strong><span style="color: red; font-size: 9.5pt;" lang="EN">x</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">:</span></strong><strong><span style="color: red; font-size: 9.5pt;" lang="EN">Key</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">="DistinctLanguageCountParameter"<strong><span style="color: red; font-size: 9.5pt;" lang="EN">&nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Property</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">="Employees.Languages.Name"<strong><span style="color: red; font-size: 9.5pt;" lang="EN">&nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN"><strong><span style="color: red; font-size: 9.5pt;" lang="EN">Distinct</span></strong><strong><span style="color: blue; font-size: 9.5pt;" lang="EN">="True"</span></strong></span></strong></span></strong> /&gt;</span></strong><strong><span style="color: black; font-size: 9.5pt;" lang="EN">&nbsp;&nbsp;&nbsp;</span></strong></code></span></strong></code></span></strong></code></p>
<p><code><strong><span style="font-size: 9.5pt; color: black;" lang="EN"><code><strong><span style="font-size: 9.5pt; color: black;" lang="EN"><code><strong></strong></code></span></strong></code></span></strong></code><code><strong><span style="font-size: 9.5pt; color: black;" lang="EN"><code><strong><span style="font-size: 9.5pt; color: black;" lang="EN"><code><strong><span style="font-size: 9.5pt; color: black;" lang="EN"><code><strong></strong></code></span></strong></code></span></strong></code></span></strong></code><code><strong><span style="font-size: 9.5pt; color: black;" lang="EN"><code><strong><span style="font-size: 9.5pt; color: black;" lang="EN"><code><strong></strong></code></span></strong></code></span></strong></code><code><strong><span style="color: black; font-size: 9.5pt;" lang="EN">&nbsp;</span></strong><span style="color: black; font-size: 9.5pt;" lang="EN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue; font-size: 9.5pt;" lang="EN">&lt;/</span><span style="color: #a31515; font-size: 9.5pt;" lang="EN">ResourceDictionary</span><span style="color: blue; font-size: 9.5pt;" lang="EN">&gt;<br /></span><span style="color: black; font-size: 9.5pt;" lang="EN">&nbsp;&nbsp; </span><span style="color: blue; font-size: 9.5pt;" lang="EN">&lt;/</span><span style="color: #a31515; font-size: 9.5pt;" lang="EN">Application.Resources</span><span style="color: blue; font-size: 9.5pt;" lang="EN">&gt;<br />&lt;/</span><span style="color: #a31515; font-size: 9.5pt;" lang="EN">Application</span><span style="color: blue; font-size: 9.5pt;" lang="EN">&gt;</span></code></p>
<p>The count parameter declaration in the above code can be used to concatenate languages of all employees in all departments. LanguageCountParameter finds all count of languages whereas DistinctLanguageCountParameter finds distinct count of languages.</p>
<p>Following code displays total language count while binding.<span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">&nbsp;</span></span></p>
<p>&lt;<span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">TextBlock</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> </span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;">Text</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">="{</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">Binding</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> Company</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">.Departments,</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Converter</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">={</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">StaticResource</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> CountConverter</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">},</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; ConverterParameter</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">={</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">StaticResource</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> LanguageConcatenationParameter</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">}}"</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Style</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">="{</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">StaticResource</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> BasicTextStyle</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">}" /&gt;</span></span></span></p>
<p>Following code displays distinct language count while binding.<span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">&nbsp;</span></span></p>
<p>&lt;<span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">TextBlock</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> </span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;">Text</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">="{</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">Binding</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> Company</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">.Departments,</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Converter</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">={</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">StaticResource</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> CountConverter</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">},</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; ConverterParameter</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">={</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">StaticResource</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> DistinctLanguageConcatenationParameter</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">}}"</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Style</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">="{</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">StaticResource</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"><span style="font-size: 9.5pt; font-family: Consolas; color: #ff0000;"> BasicTextStyle</span></span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;"><span style="font-size: 9.5pt; font-family: Consolas; color: #0000ff;">}" /&gt;</span></span></span></p>


</body>
</html>
